package com.crm.controller;

import com.crm.result.Result;
import com.crm.service.IndexService;
import com.crm.vo.BaseInfoVo;
import com.crm.vo.VulnerabilityVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * 首页查询相关接口
 */
@RestController
@Slf4j
public class IndexContriller {
    @Autowired
    private IndexService indexService;
    /**
     * 基础数据
     *
     * GET
     *http://175.178.254.14/api/index/getBaseInfo?beginCreateTime=2025-05-07&endCreateTime=2025-06-06
     */
    @GetMapping("/index")
    public Result<BaseInfoVo> getJCDate(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginCreateTime, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endCreateTime){
        BaseInfoVo jcDate = indexService.getJCDate(beginCreateTime, endCreateTime);
        return Result.success(jcDate);
    }

    /**
     * 线索转化漏斗
     * GET
     * http://localhost:8888/api/report/getVulnerabilityMap/2025-05-07/2025-06-06
     */
    @GetMapping("/report/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
    public Result<VulnerabilityVo> getVulnerabilityMap(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginCreateTime,@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endCreateTime){
        VulnerabilityVo jcDate = indexService.getLDDate(beginCreateTime, endCreateTime);
        return Result.success(jcDate);
    }

    @GetMapping("/index/businessChangeStatistics")
    public Result getBusiness( String beginCreateTime, String endCreateTime){
        log.info("统计商机信息{}",beginCreateTime,endCreateTime);
        return Result.success();
    }

    @GetMapping("/index/salesStatistic")
    public Result getSale(String beginCreateTime, String endCreateTime){
        log.info("统计销售信息{}",beginCreateTime,endCreateTime);
        return Result.success();
    }

}
